import { defHttp } from '/@/utils/http/axios';
import setting from '/@/settings/projectSetting';
import { ContentTypeEnum } from '/@/enums/httpEnum';

const Api = {
  queryList: `${setting.interfacePrefix}/query/list`, // 查询列表
  queryCreate: `${setting.interfacePrefix}/query/create`, // 查询列表新增
  queryUpdate: `${setting.interfacePrefix}/query/update`, // 查询列表修改
  queryDel: `${setting.interfacePrefix}/query/del`, // 查询列表删除
  queryGetQueryPrivilege: `${setting.interfacePrefix}/query/getQueryPrivilege`, // 查询列表获取授权
  queryDesignerEditPage: `${setting.interfacePrefix}/query/designerEditPage`, // 查询设计器页面
  queryGetConditions: `${setting.interfacePrefix}/query/getConditions`, // 取得设计器中配置的条件
  queryGetMainFormQuery: `${setting.interfacePrefix}/query/getMainFormQuery`, // 取得主表的查询
  queryCreateNew: `${setting.interfacePrefix}/query/createNew`, // 新建查询id
  querySetQueryPrivilege: `${setting.interfacePrefix}/query/setQueryPrivilege`, // 新建查询id
  queryCreateForScript: `${setting.interfacePrefix}/query/createForScript`, // 自由查询创建
  queryEditScriptPage: `${setting.interfacePrefix}/query/editScriptPage`, // 自由查询编辑获取
  queryUpdateForScript: `${setting.interfacePrefix}/query/updateForScript`, // 自由查询编辑保存
  queryListWarrent: `${setting.interfacePrefix}/query/listWarrent`, // 授权查询
  queryListQueryResultPage: `${setting.interfacePrefix}/query/listQueryResultPage`, // 普通查询结果页面
  queryListQueryResult: `${setting.interfacePrefix}/query/listQueryResult`, // 普通查询列表
  queryModifyConditionFieldCode: `${setting.interfacePrefix}/query/modifyConditionFieldCode`, // 修改普通查询的条件 然后刷新查询
  queryExport: `${setting.interfacePrefix}/query/export`, // 普通查询导出

  queryListQueryResultPageByScript: `${setting.interfacePrefix}/query/listQueryResultPageByScript`, // 自由查询结果页面
  queryListQueryResultByScript: `${setting.interfacePrefix}/query/listQueryResultByScript`, // 自由查询结果
  queryGetConditionsForScript: `${setting.interfacePrefix}/query/getConditionsForScript`, // 取得自由查询的条件
  // queryGetConditionsForScript: `${setting.interfacePrefix}/query/listQueryResultByScript?mode=changeCondValue&action=searchInResult`, // 更改条件后点确定按钮继续搜索
  queryGetSearchConditionsForScript: `${setting.interfacePrefix}/query/getSearchConditionsForScript`, // 取得自由查询的搜索条件
  // queryGetConditionsForScript: `${setting.interfacePrefix}/query/listQueryResultByScript?mode=filter&action=searchInResult`, // 更改搜索条件
  queryExportByScript: `${setting.interfacePrefix}/query/exportByScript`, // 自由查询导出
  queryModifyColProps: `${setting.interfacePrefix}/query/modifyColProps`, // 修改查询结果的列
  queryResetCol: `${setting.interfacePrefix}/query/resetCol`, // 重置列
  queryUpdateConditions: `${setting.interfacePrefix}/query/updateConditions`, // 修改普通查询条件
};

export const getQueryResetCol = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryResetCol,
    params,
  });
export const getQueryList = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryList,
    params,
  });
export const getQueryCreate = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryCreate,
    params,
  });
export const getQueryUpdate = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryUpdate,
    params,
    headers: { 'Content-Type': ContentTypeEnum.JSON },
  });
export const getQueryDel = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryDel,
    params,
  });
export const getQueryGetQueryPrivilege = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryGetQueryPrivilege,
    params,
  });
export const getQueryDesignerEditPage = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryDesignerEditPage,
    params,
  });
export const getQueryGetConditions = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryGetConditions,
    params,
  });
export const getQueryGetMainFormQuery = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryGetMainFormQuery,
    params,
  });
export const getQueryCreateNew = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryCreateNew,
    params,
  });
export const getQueryCreateForScript = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryCreateForScript,
    params,
  });
export const getQueryEditScriptPage = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryEditScriptPage,
    params,
  });
export const getQueryUpdateForScript = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryUpdateForScript,
    params,
  });
export const getQueryListWarrent = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryListWarrent,
    params,
  });
export const getQueryListQueryResultPage = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryListQueryResultPage,
    params,
  });
export const getQueryListQueryResult = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryListQueryResult,
    params,
  });
export const getQueryListQueryResultPageByScript = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryListQueryResultPageByScript,
    params,
  });
export const getQueryListQueryResultByScript = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryListQueryResultByScript,
    params,
  });
export const getQueryGetConditionsForScript = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryGetConditionsForScript,
    params,
  });
export const getQueryGetSearchConditionsForScript = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryGetSearchConditionsForScript,
    params,
  });
export const getQueryModifyConditionFieldCode = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryModifyConditionFieldCode,
    params,
  });
export const getQueryExport = (params?: any) =>
  defHttp.post<any>(
    {
      url: Api.queryExport,
      params,
      responseType: 'blob',
    },
    {
      isTransformResponse: false,
    },
  );
export const getQueryExportByScript = (params?: any) =>
  defHttp.post<any>(
    {
      url: Api.queryExportByScript,
      params,
      responseType: 'blob',
    },
    {
      isTransformResponse: false,
    },
  );
export const getQueryModifyColProps = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryModifyColProps,
    params,
  });

export const getQueryUpdateConditions = (params?: any) =>
  defHttp.post<any>({
    url: Api.queryUpdateConditions,
    params,
    headers: { 'Content-Type': ContentTypeEnum.JSON },
  });
export const getQuerySetQueryPrivilege = (params?: any) =>
  defHttp.post<any>({
    url: Api.querySetQueryPrivilege,
    params,
  });
